import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import { getModuleFiles } from '@/utils/common'

const modulesFiles: any = import.meta.glob('./modules/*.ts', { eager: true })
const modules = getModuleFiles(modulesFiles)

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'Index',
    component: () => import('@/views/index.vue'),
    meta: { title: '首页' }
  },
  ...modules
]

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_APP_BASE_PATH),
  routes,
})

export default router